<template>
    <div>
        <div class="news-center">
            <h1>新闻中心</h1>
            <h2>New Center</h2>
        </div>
        <ul class="news-list mt-20 mb-20">
            <li class="news-item" v-for="item in newsList" :key="item.articleId">
                <!-- <div class="date-container">
                    <div class="day">{{ getDatePart(item.date)[2] }}</div>
                    <div>{{ getDatePart(item.date)[0] }}-{{ getDatePart(item.date)[1] }}</div>
                </div> -->
                <div class="title">
                    <a href="/">{{ item.title }}</a>
                    <span>{{ getDatePart(item.date)[0] }}-{{ getDatePart(item.date)[1] }}</span>
                </div>
            </li>
        </ul>
        <div class="news-button-wrap">
            <div class="news-button">
                <a href="/news">更多新闻 ></a>
            </div>
        </div>
    </div>
</template>
<script setup>
import { ref } from 'vue'

// TODO 从接口中获取
const newsList = ref([
    {
        title: 'E7E16|菲斯生物邀您共聚CPHI & PMEC China 2024',
        date: '2024-06-19',
        articleId: 1,
    },
    {
        title: '浅谈药物杂质标准品定量研究方法之定量核磁',
        date: '2024-06-07',
        articleId: 2,
    },
    {
        title: '6月SINCO最新入库杂质对照品，现货等您来选！',
        date: '2024-06-05',
        articleId: 3,
    },
])

const getDatePart = (dateString) => {
    const parts = dateString.split('-')
    return parts
}
</script>
<style lang="scss" scoped>
.news-center {
    h1 {
        text-align: center;
        color: #09a4c3;
        font-size: 28px;
    }

    h2 {
        text-align: center;
        color: #999;
        font-size: 14px;
    }
}

.news-button-wrap {
    width: 150px;
    margin: 40px auto;
}
.news-button {
    width: 150px;
    height: 44px;
    line-height: 42px;
    text-align: center;
    border: 1px solid rgba(9, 174, 212, 1);
    a {
        color: #09aed4;
        text-decoration: none;
    }
    &:hover {
        background-color: rgba(9, 164, 195, 1);
        border-color: transparent;
        a {
            font-weight: bold;
            color: #fff;
        }
    }
}

// 子集样式
.news-list {
    .news-item {
        list-style: none;
        border-bottom: 1px dotted #dbd4cd;
        margin: 20px 10px;
        display: flex;

        .date-container {
            width: 80px;
            height: 80px;
            background-color: #09aed4;
            text-align: center;
            color: #fff;
            margin-bottom: 12px;
            margin-left: 30px;
            .day {
                padding-top: 20px;
                font-size: 24px;
            }
        }

        .title {
            font-size: 16px;
            font-weight: bold;
            padding-bottom: 10px;

            a {
                padding-bottom: 6px;
                text-decoration: none;
                &:hover {
                    color: #09aed4;
                }
                &:visited {
                    color: initial;
                }

                display: block;
                width: 90%;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                color: #666666 !important;
            }

            span {
                font-weight: normal;
                line-height: 1.5;
                color: #929292;
            }
        }
    }
}
</style>
